﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yu.Cms.Common;

namespace Yu.Cms.Web.UserCtrl.Admin
{
    public partial class SysUser : BaseCtrl
    {

      
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string UserName = HttpContext.Current.User.Identity.Name;

                this.OnStart(UserName);
                 string act = YuRequest.GetQueryString("act");
                 if (act.ToLower() == "edit")
                 {
                     string username = YuRequest.GetFormString("username");
                     string userpass = YuRequest.GetFormString("userpass");
                     string newpass = YuRequest.GetFormString("newpass");

                     Yu.Cms.Model.Admin mAdmin = bllAdmin.GetModel(UserName);
                     if (mAdmin != null)
                     {
                         if (mAdmin.Password == Utils.Encrypt(userpass))
                         {
                                 mAdmin.UserName = username;
                                 mAdmin.Password = Utils.Encrypt(newpass);
                                 bllAdmin.Update(mAdmin);
                                 Response.Write(0);
                                 Response.End();                           
                            
                         }
                         else
                         {
                             Response.Write(1);
                             Response.End(); 
                         }
                     }
                     else
                     {
                         Response.Write(2);
                         Response.End(); 
                     }
                 }
            }
        }

        protected void OnStart(string UserName)
        {
            txtUser.Value = UserName;
        }


       

       
    }
}